package company.meituan_F;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

// 读题读题读题！！！
public class M1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long l = sc.nextLong();
        List<String> list = new ArrayList<>();
        // 扩大4倍的数应该也要在区间范围内
        for (long i = 1; i * 4 <= l; i++) {
            StringBuffer sb = new StringBuffer(i + "");
            Long tmp = Long.parseLong(String.valueOf(sb.reverse()));
            if (i * 4 == tmp) {
                list.add(i + " " + tmp);
            }
        }
        if (list.size() == 0)
            System.out.println(0);
        else
            for (String s : list) {
                System.out.println(s);
            }
    }

}
